package janino;

import org.codehaus.commons.compiler.util.resource.ResourceFinder;
import org.codehaus.janino.ClassBodyEvaluator;
import org.codehaus.janino.CachingJavaSourceClassLoader;
import org.codehaus.janino.SimpleCompiler;
import org.codehaus.janino.util.ClassFile;

import java.lang.reflect.Method;
public class CachingJavaSourceClassLoaderExample {
    public static void main(String[] args) throws Exception {


        // Define the Java source code
        /*String javaCode = "public class HelloWorld { public static void main(String[] args) { System.out.println(\"Hello, World\"); } }";
        // Create a CachingJavaSourceClassLoader
        CachingJavaSourceClassLoader classLoader = new CachingJavaSourceClassLoader(CachingJavaSourceClassLoaderExample.class.getClassLoader());
        // Compile the Java source code and load the generated class
        Class<?> helloWorldClass = classLoader.loadClass("HelloWorld", javaCode);
        // Create an instance of the HelloWorld class and invoke the 'main' method
        Object helloWorldInstance = helloWorldClass.getDeclaredConstructor().newInstance();
        Method mainMethod = helloWorldClass.getMethod("main", String[].class);
        mainMethod.invoke(null, new Object[]{new String[0]});*/
    }
}